import 'package:json_annotation/json_annotation.dart';
import 'user.dart';
part 'moment_model.g.dart';

@JsonSerializable()
class MomentModel {
  @JsonKey(defaultValue: [])
  final List<Moment> moments;
  @JsonKey(defaultValue: 0)
  final int lastId;
  @JsonKey(defaultValue: 0)
  final int pageSize;

  const MomentModel({
    required this.moments,
    required this.lastId,
    required this.pageSize,
  });

  factory MomentModel.fromJson(Map<String, dynamic> json) =>
      _$MomentModelFromJson(json);

  Map<String, dynamic> toJson() => _$MomentModelToJson(this);
}

@JsonSerializable()
class Moment {
  @JsonKey(defaultValue: 0)
  final int momentId;
  @JsonKey(defaultValue: 0)
  final int type;
  @JsonKey(defaultValue: '')
  final String content;
  @JsonKey(defaultValue: '')
  final String videoUrl;
  @JsonKey(defaultValue: '')
  final String videoCover;
  @JsonKey(defaultValue: 0)
  final int videoSeconds;
  @JsonKey(defaultValue: 0)
  final int videoWidth;
  @JsonKey(defaultValue: 0)
  final int videoHeight;
  @JsonKey(defaultValue: 0)
  final int videoCoverWidth;
  @JsonKey(defaultValue: 0)
  final int videoCoverHeight;
  @JsonKey(defaultValue: [])
  final List<String> picUrls;
  @JsonKey(defaultValue: 0)
  int likeCount;
  @JsonKey(defaultValue: 0)
  final int replyCount;
  @JsonKey(defaultValue: 0)
  final int createTime;
  @JsonKey(defaultValue: '')
  final String videoWaterMarkUrl;
  final User? userInfo;
  @JsonKey(defaultValue: [])
  final List<User> replyUserInfos;
  @JsonKey(defaultValue: false)
  bool focusOn;
  @JsonKey(defaultValue: false)
  bool like;
  @JsonKey(defaultValue: false)
  final bool inRoom;
  @JsonKey(defaultValue: '')
  final String ipBelong;

  Moment({
    required this.momentId,
    required this.type,
    required this.content,
    required this.videoUrl,
    required this.videoCover,
    required this.videoSeconds,
    required this.videoWidth,
    required this.videoHeight,
    required this.videoCoverWidth,
    required this.videoCoverHeight,
    required this.picUrls,
    required this.likeCount,
    required this.replyCount,
    required this.createTime,
    required this.videoWaterMarkUrl,
    this.userInfo,
    required this.replyUserInfos,
    required this.focusOn,
    required this.like,
    required this.inRoom,
    required this.ipBelong,
  });

  factory Moment.fromJson(Map<String, dynamic> json) =>
      _$MomentFromJson(json);

  Map<String, dynamic> toJson() => _$MomentToJson(this);
}
